package tech.xs.sys.domain.bo.permission;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import tech.xs.common.framework.domain.bo.PageBo;
import tech.xs.common.framework.domain.entity.BaseEntity;
import tech.xs.common.domain.enums.YesNoEnum;
import tech.xs.sys.domain.entity.SysPermission;

@Getter
@Setter
@ToString
public class PagePermissionBo extends PageBo<SysPermission> {

    private String likeCode;

    private String likeName;

    private YesNoEnum permissionStatus;

    public LambdaQueryWrapper<SysPermission> query() {
        return Wrappers.<SysPermission>lambdaQuery()
                .like(StrUtil.isNotBlank(likeCode), SysPermission::getCode, likeCode)
                .like(StrUtil.isNotBlank(likeName), SysPermission::getName, likeName)
                .eq(permissionStatus != null, SysPermission::getPermissionStatus, permissionStatus)
                .orderByDesc(BaseEntity::getCreatedTime);
    }

}
